package com.lingxu.base.system.manage.controller;

import com.lingxu.base.common.api.vo.Result;
import com.lingxu.base.system.manage.entity.*;
import com.lingxu.base.system.manage.service.ISysRoleMenuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@Api(tags="角色菜单信息")
@RestController
@RequestMapping("/system/manage/sysRoleMenu")
public class SysRoleMenuController {

	@Resource
	private ISysRoleMenuService sysRoleMenuService;


	@ApiOperation(value="角色菜单信息-根据角色获取菜单树（包含已获取和未获取）只需要传roleid", notes="角色菜单信息-根据角色获取菜单树（包含已获取和未获取）只需要传roleid")
	@PostMapping(value = "/queryMenuTreesByRoleid")
	public Result<?> queryMenuTreesByUserid(@RequestBody SysRoleMenuUserVo sysRoleMenuUserVo) {
		String roleid = sysRoleMenuUserVo.getRoleid();
		Result result = new Result();
		MenuTrees tree = new MenuTrees();
		List<MenuTree> list1 = sysRoleMenuService.queryExistMenuTreeByRoleid(roleid);
		List<MenuTree> list2 = sysRoleMenuService.queryNotExistMenuTreeByRoleid(roleid);
		tree.setList1(list1);
		tree.setList2(list2);
		result.setResult(tree);
		result.setCode(200);
		result.setSuccess(true);
		return result;
	}
	@ApiOperation(value="角色菜单信息-根据角色获取菜单树（已获取）", notes="角色菜单信息-根据角色获取菜单树（已获取）")
	@PostMapping(value = "/queryExistMenuTreesByRoleid")
	public Result<?> queryExistMenuTreesByUserid(@RequestBody SysRoleMenuUserVo sysRoleMenuUserVo) {
		String roleid = sysRoleMenuUserVo.getRoleid();
		Result result = new Result();
		List<MenuTree> list1 = sysRoleMenuService.queryExistMenuTreeByRoleid(roleid);
		result.setResult(list1);
		result.setCode(200);
		result.setSuccess(true);
		return result;
	}
	@ApiOperation(value="角色菜单信息-根据角色获取菜单树（未获取）", notes="角色菜单信息-根据角色获取菜单树（未获取）")
	@PostMapping(value = "/queryNotExistMenuTreesByRoleid")
	public Result<?> queryNotExistMenuTreesByUserid(@RequestBody SysRoleMenuUserVo sysRoleMenuUserVo) {
		String roleid = sysRoleMenuUserVo.getRoleid();
		Result result = new Result();
		List<MenuTree> list1 = sysRoleMenuService.queryNotExistMenuTreeByRoleid(roleid);
		result.setResult(list1);
		result.setCode(200);
		result.setSuccess(true);
		return result;
	}




}
